package com.zjitc.service;

import com.zjitc.common.ServerResponse;
import com.zjitc.pojo.User;
import com.zjitc.vo.user.ForgetPasswordDemo;
import com.zjitc.vo.PageModel;
import org.springframework.web.servlet.ModelAndView;

import javax.servlet.http.HttpSession;
import java.io.UnsupportedEncodingException;
import java.security.NoSuchAlgorithmException;
import java.util.List;

/**
 * Create By IntelliJ IDEA
 *
 * @author: myq
 * @create-Time: 2017/11/7  15:55
 */
public interface UserService {
    /**
     * 注册
     *
     * @param user
     * @return
     */
    User regiser(User user);

    /**
     * 登陆
     *
     * @param username
     * @param password
     * @param session
     * @return
     * @throws UnsupportedEncodingException
     * @throws NoSuchAlgorithmException
     */
    ServerResponse<User> login(String username, String password, HttpSession session);

    /**
     * 管理员登陆
     *
     * @param username
     * @param password
     * @return
     */
    User adminLogin(String username, String password);

    /**
     * 检查用户名是否被占用
     *
     * @param username
     * @return
     */
    User checkUsername(String username);

    /**
     * 查看所有用户信息
     *
     * @param pageid
     * @param count
     * @return
     */
    PageModel<User> findall(int pageid, int count);

    List<User> getUserInfoList();

    int getUserCount();

    /**
     * 更新用户信息
     *
     * @param user
     */
    boolean update(User user);

    /**
     * 查看用户
     *
     * @param uid
     * @return
     */
    User findbyuid(String uid);

    /**
     * 删除用户
     *
     * @param uid
     */
    boolean deluser(String uid);

    /**
     * 确认密码
     *
     * @param password
     * @param verifypassword
     * @return
     */
    ServerResponse checkpassword(String password, String verifypassword);

//  /**
//   * 发送邮件验证
//   * @param demo
//   */
//  void forgetSendEmail(ForgetPasswordDemo demo);

    /**
     * 检查对应验证码是否正确
     *
     * @param demo
     * @param code
     * @return
     */
    ServerResponse forgetcheckcode(ForgetPasswordDemo demo, String code);

    /**
     * 通过username 找到 对应的uid
     *
     * @param username
     * @return
     */
    String finduidByusername(String username);

    /**
     * 忘记密码的重置密码
     *
     * @param user
     * @return
     */
    boolean forgetResetPassword(User user);

    /**
     * 重置密码
     *
     * @param uid
     * @param oldPassword
     * @param newPassword
     * @param session
     * @return
     */
    ServerResponse resetPassword(String uid, String oldPassword, String newPassword, HttpSession session);

    /**
     * 查看用户收藏商品
     *
     * @param session
     * @param page
     * @return
     */
    ModelAndView searchMyCollect(HttpSession session, String page);

    /**
     * 发送手机验证码
     *
     * @param phone
     * @param session
     * @return
     */
    ServerResponse sendPhoneCode(String phone, HttpSession session);

    /**
     * 验证手机验证码
     *
     * @param code
     * @return
     */
    boolean checkCode(String phone, String code);

    boolean updatePassword(String uid, String password);

    int updateIntegral(Integer integral, String uid);

    String updateState(String username);

    List<User> findUserSearch(String username);

    String getUserPhone(String uid);
}
